package com.demo.provider.impl;

import com.demo.base.pojo.Clothetype;
import com.demo.base.pojo.Clothinginfo;
import com.demo.base.pojo.Styletype;
import com.demo.base.pojo.pagedDate;
import com.demo.base.service.ClothinginfoService;
import com.demo.provider.dao.ClothinginfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ClothinginfoServiceimpl implements ClothinginfoService {
   @Resource
   ClothinginfoMapper clothinginfoMapper;

    public pagedDate<Clothinginfo> pagedDate(int gender, int age, String color, int styleid, int typeid, int pageIndex, int pageSize) {
        int from=(pageIndex-1)*pageSize;
        List<Clothinginfo> list = clothinginfoMapper.getList(gender, age, color, styleid, typeid, from, pageSize);
        int cnt = clothinginfoMapper.getCount(gender, age, color, styleid, typeid);
        pagedDate<Clothinginfo>pagedDate=new pagedDate<>(pageSize,pageIndex,cnt, list);
        System.out.println(pagedDate.getPageSize()+":"+pagedDate.getTotalCount());
        return pagedDate;
    }

    @Override
    public List<Styletype> getall() {
        return clothinginfoMapper.getall();
    }

    @Override
    public List<Clothetype> gettype() {
        return clothinginfoMapper.gettype();
    }

    @Override
    public Clothinginfo info(int id) {
        return clothinginfoMapper.info(id);
    }
}
